package com.qxkj.mysql.multidb.dbRoute.config;

import com.qxkj.mysql.multidb.dbRoute.base.DynamicDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * Copyright © 2018年 ziniuxiaozhu. All rights reserved.
 *
 * @Author 临江仙 hzqiuxm@163.com
 * TODO:亲爱的临江仙，请写点注释吧...........
 * @Date 2018/9/5 10:44
 */
@Configuration
public class CommonBean {

    @Bean
    DynamicDataSource dynamicDataSource(){

        DynamicDataSource dynamicDataSource = new DynamicDataSource();

        Map<Object, Object> targetDataSources = new HashMap<>();
        targetDataSources.put("db0","dataSource0");
        targetDataSources.put("db1","dataSource1");
        targetDataSources.put("db2","dataSource2");
        dynamicDataSource.setTargetDataSources(targetDataSources);

        return dynamicDataSource;
    }
}
